<html>
<head><meta charset="utf-8"><title>need for arrow operator (or similar) · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html">need for arrow operator (or similar)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="164994461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/164994461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#164994461">(May 06 2019 at 16:06)</a>:</h4>
<p><a href="https://internals.rust-lang.org/t/need-for-operator-for-unsafe-code-guidelines/10022" target="_blank" title="https://internals.rust-lang.org/t/need-for-operator-for-unsafe-code-guidelines/10022">https://internals.rust-lang.org/t/need-for-operator-for-unsafe-code-guidelines/10022</a></p>



<a name="164994465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/164994465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#164994465">(May 06 2019 at 16:06)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> ^</p>



<a name="165020067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020067">(May 06 2019 at 21:19)</a>:</h4>
<p>Yes yes please!</p>



<a name="165020151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020151">(May 06 2019 at 21:20)</a>:</h4>
<p>I am too tired right now to think about whether this changes the story for <code>&amp;raw [const|mut] &lt;expr&gt;</code>... but on first sight I think it would not.</p>



<a name="165020446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020446">(May 06 2019 at 21:24)</a>:</h4>
<p>I don't <em>100%</em> understand what this arrow operator would do</p>



<a name="165020482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020482">(May 06 2019 at 21:25)</a>:</h4>
<p>oh, like, it is <em>literally</em> the <code>-&gt;</code> from C</p>



<a name="165020497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020497">(May 06 2019 at 21:25)</a>:</h4>
<p>this is just because <code>(*foo).bar</code> is annoying to write?</p>



<a name="165020505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020505">(May 06 2019 at 21:25)</a>:</h4>
<p><code>ptr-&gt;field</code> would be either <code>(*ptr).field</code>, or maybe a raw ptr to that.</p>



<a name="165020512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020512">(May 06 2019 at 21:25)</a>:</h4>
<blockquote>
<p>this is just because <code>(*foo).bar</code> is annoying to write?</p>
</blockquote>
<p>write and read</p>



<a name="165020517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020517">(May 06 2019 at 21:25)</a>:</h4>
<p>could we just define <code>-&gt;</code> only on raw pointers?</p>



<a name="165020563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020563">(May 06 2019 at 21:26)</a>:</h4>
<p>like, <code>(*x.foo().bar()).field1.field2</code></p>



<a name="165020566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020566">(May 06 2019 at 21:26)</a>:</h4>
<p>in which case, one can think of them as "C pointers"</p>



<a name="165020574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020574">(May 06 2019 at 21:26)</a>:</h4>
<p>which...seems like a pretty accurate mental model?</p>



<a name="165020579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020579">(May 06 2019 at 21:26)</a>:</h4>
<p>i.e., just as in C you would do <code>foo-&gt;bar</code>...</p>



<a name="165020595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020595">(May 06 2019 at 21:26)</a>:</h4>
<p>but also, pointers in C code that you link to are literally also treated like raw pointers</p>



<a name="165020598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020598">(May 06 2019 at 21:26)</a>:</h4>
<p>(from UCG perspective)</p>



<a name="165020645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165020645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165020645">(May 06 2019 at 21:27)</a>:</h4>
<p>anyway, seems..ok to me</p>



<a name="165021003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165021003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165021003">(May 06 2019 at 21:32)</a>:</h4>
<blockquote>
<p>could we just define <code>-&gt;</code> only on raw pointers?</p>
</blockquote>
<p>yeah, there's probably no good reason to have it on references</p>



<a name="165022411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165022411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165022411">(May 06 2019 at 21:54)</a>:</h4>
<p>Can't raw pointers just use <code>.</code> like references? (Still requiring <code>unsafe</code>.)<br>
IIRC, something like this was planned eventually when unsafety checking was moved to MIR.</p>



<a name="165028976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165028976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165028976">(May 06 2019 at 23:39)</a>:</h4>
<p>This is counter to my memory, in which it was generally understood that <code>.</code> on raw pointers (especially when they're nullable) is waaay too dangerous.</p>



<a name="165029042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029042">(May 06 2019 at 23:40)</a>:</h4>
<p>Specifically, I was able to land the new ptr methods specifically under the rationale that raw pointers will never implement Deref-style . (and also, we already had a few methods so it was too late to stop it)</p>



<a name="165029161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029161">(May 06 2019 at 23:42)</a>:</h4>
<p>I think familiarity of <code>foo-&gt;bar</code> in C++ et. al works against us here; I think it might encourage overuse of raw pointers where references would otherwise suffice</p>



<a name="165029179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029179">(May 06 2019 at 23:42)</a>:</h4>
<p>no that's the point, we have discouraged raw pointers too much, and it's literally making rust programs unsound</p>



<a name="165029186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029186">(May 06 2019 at 23:43)</a>:</h4>
<p>you literally should avoid using references as much as possible once you're using raw pointers</p>



<a name="165029212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029212">(May 06 2019 at 23:43)</a>:</h4>
<p><span class="user-mention" data-user-id="137587">@Gankro</span>  I mean for normal uses where you don't need raw pointers</p>



<a name="165029214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029214">(May 06 2019 at 23:43)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> I <em>think</em> if we did proposal 3, it would eliminate most uses for &amp;raw? Most obvious exception being indexing results, but it wouldn't be that unreasonable to make *const [T] indexing work like my proposed raw pointer dot operator</p>



<a name="165029273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029273">(May 06 2019 at 23:44)</a>:</h4>
<p><code>foo.*bar</code> seems better if we're going with new syntax tbh</p>



<a name="165029333"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029333" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029333">(May 06 2019 at 23:45)</a>:</h4>
<p>I am super dubious of people considering raw pointers more convenient than references</p>



<a name="165029393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029393">(May 06 2019 at 23:46)</a>:</h4>
<p><span class="user-mention" data-user-id="137587">@Gankro</span> I feel we already have such overuse by people coming from C &amp; C++</p>



<a name="165029406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029406">(May 06 2019 at 23:46)</a>:</h4>
<p>got any citations on that..?</p>



<a name="165029425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029425">(May 06 2019 at 23:47)</a>:</h4>
<p>not on hand</p>



<a name="165029453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029453">(May 06 2019 at 23:47)</a>:</h4>
<p>imo this also doesn't belong on the roadmap for 2019</p>



<a name="165029528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029528">(May 06 2019 at 23:49)</a>:</h4>
<p>is <a href="https://github.com/rust-lang/rfcs/pull/2582" target="_blank" title="https://github.com/rust-lang/rfcs/pull/2582">https://github.com/rust-lang/rfcs/pull/2582</a> also similarly not going to be considered for 2019?</p>



<a name="165029622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165029622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165029622">(May 06 2019 at 23:50)</a>:</h4>
<p>No that one will because it's both preexisting and makes something possible which otherwise isn't and moreover facilitates closing soundness holes.</p>



<a name="165030326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030326">(May 07 2019 at 00:04)</a>:</h4>
<p>I really don't like adding <code>-&gt;</code> without adding a way to overload it</p>



<a name="165030332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030332">(May 07 2019 at 00:04)</a>:</h4>
<p>but <code>*.</code> seems reasonable, imo</p>



<a name="165030354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030354">(May 07 2019 at 00:05)</a>:</h4>
<p>what if my proposal is an effective alternative to <a href="https://github.com/rust-lang/rust/issues/2582" target="_blank" title="https://github.com/rust-lang/rust/issues/2582">#2582</a> ?</p>



<a name="165030378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030378">(May 07 2019 at 00:05)</a>:</h4>
<p>I also don't like <code>.*</code> b/c it seems out of order</p>



<a name="165030507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030507">(May 07 2019 at 00:08)</a>:</h4>
<p>Also TIL C++ has .*, and I believe it means what I was proposing raw_ptr.field is</p>



<a name="165030536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030536">(May 07 2019 at 00:08)</a>:</h4>
<p>it's very different</p>



<a name="165030553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030553">(May 07 2019 at 00:09)</a>:</h4>
<p>ah; <code>foo*.bar</code> then -- seems better than <code>-&gt;</code></p>



<a name="165030568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030568">(May 07 2019 at 00:09)</a>:</h4>
<p><code>x.*y</code>, by default, takes <code>cls* x; T cls::* y;</code>, and does a member-pointer lookup by <code>y</code> on <code>x</code></p>



<a name="165030623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030623">(May 07 2019 at 00:10)</a>:</h4>
<p>what's the solution to *.'s ambiguity?</p>



<a name="165030629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030629">(May 07 2019 at 00:10)</a>:</h4>
<p>i.e:</p>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="n">Foo</span> <span class="p">{</span>
  <span class="kt">int</span> <span class="n">x</span><span class="p">;</span>
  <span class="kt">int</span> <span class="n">y</span><span class="p">;</span>
<span class="p">};</span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
  <span class="kt">int</span> <span class="n">Foo</span><span class="o">::*</span> <span class="n">x</span> <span class="o">=</span> <span class="o">&amp;</span><span class="n">Foo</span><span class="o">::</span><span class="n">x</span><span class="p">;</span>
  <span class="n">Foo</span> <span class="n">f</span><span class="p">{};</span>
  <span class="k">return</span> <span class="n">f</span><span class="p">.</span><span class="o">*</span><span class="n">x</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>



<a name="165030643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030643">(May 07 2019 at 00:10)</a>:</h4>
<p>0.o</p>



<a name="165030645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030645">(May 07 2019 at 00:11)</a>:</h4>
<p>but also, you can overload it for any LHS and RHS types</p>



<a name="165030678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030678">(May 07 2019 at 00:11)</a>:</h4>
<p>like other binary operators</p>



<a name="165030721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030721">(May 07 2019 at 00:12)</a>:</h4>
<p>unlike <code>-&gt;</code>, which is overloaded as a unary operator</p>



<a name="165030817"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030817" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030817">(May 07 2019 at 00:14)</a>:</h4>
<p>it's not especially useful for fields, but it's really nice for methods</p>



<a name="165030986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165030986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165030986">(May 07 2019 at 00:18)</a>:</h4>
<p>it's possibly postfix deref would also be ambgious with foo * [0] (is this (*foo)[0] or mul(foo, [0])?</p>



<a name="165031184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165031184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165031184">(May 07 2019 at 00:22)</a>:</h4>
<p>hmm, point</p>



<a name="165031216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165031216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165031216">(May 07 2019 at 00:23)</a>:</h4>
<p>I was thinking specifically <code>*.</code> as an operator tho</p>



<a name="165031334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165031334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165031334">(May 07 2019 at 00:25)</a>:</h4>
<p>how can you parse that out of foo*.0, though?</p>



<a name="165032198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165032198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165032198">(May 07 2019 at 00:42)</a>:</h4>
<p>you'd parse <code>*.</code> as an operator</p>



<a name="165032202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165032202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165032202">(May 07 2019 at 00:42)</a>:</h4>
<p><code>foo *. 0</code></p>



<a name="165032223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165032223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165032223">(May 07 2019 at 00:43)</a>:</h4>
<p>it's a breaking change, but not one that should break anybody who isn't making two really poor style decisions :P</p>



<a name="165033386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165033386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165033386">(May 07 2019 at 01:09)</a>:</h4>
<p>seems unecessarily brutal</p>



<a name="165052987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165052987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165052987">(May 07 2019 at 08:40)</a>:</h4>
<blockquote>
<p>I think familiarity of <code>foo-&gt;bar</code> in C++ et. al works against us here; I think it might encourage overuse of raw pointers where references would otherwise suffice</p>
</blockquote>
<p>all current data points towards people using references when they should use raw ptrs (and causing unsoundness along the way). So I doubt this. References are still more convenient than raw ptrs even if we got <code>-&gt;</code>.</p>



<a name="165083409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165083409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165083409">(May 07 2019 at 15:45)</a>:</h4>
<blockquote>
<p>all current data points towards people using references when they should use raw ptrs (and causing unsoundness along the way).</p>
</blockquote>
<p>Do we have any data on people using pointers where they should actually be using references ? IIRC, many of the soundness bugs in actix where due to this.</p>



<a name="165083500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165083500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165083500">(May 07 2019 at 15:45)</a>:</h4>
<p>While I feel <span class="user-mention" data-user-id="137587">@Gankro</span> 's pain, my first thought was "Could we fix this with a lint ?"</p>



<a name="165083510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165083510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165083510">(May 07 2019 at 15:46)</a>:</h4>
<p>As opposed to adding an operator for this.</p>



<a name="165083632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165083632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165083632">(May 07 2019 at 15:47)</a>:</h4>
<p>Also, IMO, the main reason people don't write <code>(*x.foo().bar()).field1.field2</code> is because they don't know they need to. <br>
I don't see how <code>-&gt;</code> fixes that.</p>



<a name="165083669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165083669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165083669">(May 07 2019 at 15:47)</a>:</h4>
<p>The problem that people don't know that they have to use <code>-&gt;</code> instead of references would still be there.</p>



<a name="165108623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165108623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165108623">(May 07 2019 at 20:35)</a>:</h4>
<blockquote>
<p>Also, IMO, the main reason people don't write <code>(*x.foo().bar()).field1.field2</code> is because they don't know they need to. <br>
I don't see how <code>-&gt;</code> fixes that.</p>
</blockquote>
<p>it's annoying as hell to write and doesnt nest the right way</p>



<a name="165108776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165108776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165108776">(May 07 2019 at 20:37)</a>:</h4>
<p>postfix compsotionality is awesome, it seems like it'll even dominate the await discussion. not having it for raw ptrs is a huge pain and I sure can see that affecting people's decisions when weighing raw ptr against ref. it also makes fixing such bugs much more annoying (and much less of a search-and-replace as you need to add parentheses).<br>
but yes, we also have tons of teaching to do.</p>



<a name="165111128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165111128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165111128">(May 07 2019 at 21:06)</a>:</h4>
<p>the only reason I'm against the arrow operator is because it's not overloadable -- I really dislike adding new operators that can't be overloaded</p>



<a name="165111204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165111204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165111204">(May 07 2019 at 21:07)</a>:</h4>
<p>The only operators that shouldn't be overloadable are those which exist automatically for all types (i.e., <code>&amp;</code>)</p>



<a name="165172482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165172482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gankra <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165172482">(May 08 2019 at 15:22)</a>:</h4>
<p>What is the overloadable signature of <code>-&gt;</code> ? <code>(&amp;self) -&gt; *mut|const T</code>?</p>



<a name="165177065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165177065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nicole Mazzuca <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165177065">(May 08 2019 at 16:16)</a>:</h4>
<p>yeah</p>



<a name="165182028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182028">(May 08 2019 at 17:18)</a>:</h4>
<p>Is the method generic ?</p>



<a name="165182082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182082">(May 08 2019 at 17:19)</a>:</h4>
<p>e.g. <code>trait Arrow { fn arrow&lt;T&gt;(&amp;self) -&gt; *const T; }</code> ?</p>



<a name="165182145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182145">(May 08 2019 at 17:19)</a>:</h4>
<p>or the trait, e.g., <code>trait Arrow&lt;RHS&gt; { fn arrow(&amp;self) -&gt; *const RHS; }</code> ?</p>



<a name="165182300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182300">(May 08 2019 at 17:21)</a>:</h4>
<p>I guess it'd be like <code>Deref</code>, with an associated type</p>



<a name="165182356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182356">(May 08 2019 at 17:22)</a>:</h4>
<p>or should the type be an input parameter, e.g., <code>trait Arrow { type Output; fn arrow(&amp;self) -&gt; *const Self::Output; }</code> that one has to implement for all relevant output params, e.g., <code>impl&lt;O&gt; Arrow for MyType { type Output = O; ... }</code></p>



<a name="165182451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182451">(May 08 2019 at 17:23)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> with Deref, dereferencing a type always gives you some other constant type, but here <code>value-&gt;field0</code> and <code>value-&gt;field1</code> give you two different types</p>



<a name="165182554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182554">(May 08 2019 at 17:24)</a>:</h4>
<p><code>Deref</code> does the part before the field</p>



<a name="165182563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182563">(May 08 2019 at 17:24)</a>:</h4>
<p>so I guess <code>Arrow</code> would just the same give you the ptr to get the field from</p>



<a name="165182585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182585">(May 08 2019 at 17:25)</a>:</h4>
<p>I mean otherwise we need ptr-to-member</p>



<a name="165182613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182613">(May 08 2019 at 17:25)</a>:</h4>
<p>(which also seems fine and could help with some other things but is a much bigger endeavor)</p>



<a name="165182937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165182937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165182937">(May 08 2019 at 17:29)</a>:</h4>
<p>I don't think I follow, I thought the internals thread proposed a <code>value-&gt;field</code> that expands to <code>(*value).field</code></p>



<a name="165183048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183048">(May 08 2019 at 17:30)</a>:</h4>
<p>and that the whole point of providing a way to overload it is to be able to map <code>(input: typeof(value)) -&gt; typeof(field)</code> or similar</p>



<a name="165183052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183052">(May 08 2019 at 17:31)</a>:</h4>
<p>yes. and then to overload <code>-&gt;</code> you could have a <code>fn arrow(&amp;self) -&gt; *const Self::Out</code> or so, so it really desugars to <code>(*Arrow::arrow(&amp;value)).field</code>.</p>



<a name="165183070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183070">(May 08 2019 at 17:31)</a>:</h4>
<p>that would mirror the situation for <code>Deref</code></p>



<a name="165183087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183087">(May 08 2019 at 17:31)</a>:</h4>
<p>why can't we use <code>Deref</code> for that ?</p>



<a name="165183094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183094">(May 08 2019 at 17:31)</a>:</h4>
<p>because <code>Deref</code> returns a reference</p>



<a name="165183100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183100">(May 08 2019 at 17:31)</a>:</h4>
<p>and the entire point is that we need to make it a raw ptr</p>



<a name="165183105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183105">(May 08 2019 at 17:31)</a>:</h4>
<p>Ah, duh, yes</p>



<a name="165183198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183198">(May 08 2019 at 17:32)</a>:</h4>
<p>so arrow is just <code>trait Arrow { type Out; fn arrow(&amp;self) -&gt; *const Self::Out; }</code>, so that one can implement arrow, e.g., on <code>Box</code> to get a pointer to a field?</p>



<a name="165183362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183362">(May 08 2019 at 17:34)</a>:</h4>
<p>that is, it would be possible to, e.g., implement Deref and Arrow, with different input parameters, for the same type ?</p>



<a name="165183541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165183541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165183541">(May 08 2019 at 17:37)</a>:</h4>
<p><code>struct A(u32); struct B(i32); struct C(A, B); impl Deref&lt;Output = A&gt; for C { ... } impl Arrow&lt;Output = B&gt; for C { ... }; </code> ?</p>



<a name="165187949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need%20for%20arrow%20operator%20%28or%20similar%29/near/165187949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/need.20for.20arrow.20operator.20(or.20similar).html#165187949">(May 08 2019 at 18:26)</a>:</h4>
<p>hm that's not nice. but if people really want to shoot themselves in the foot...</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>